/**
 * Copyright (C), 2020, 安徽贝慕信息科技有限公司
 * FileName: BackendApiController
 * Author:   Allen
 * Date:     2020/8/26 11:14
 * Description: 后端开放API业务处理Controller
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bim.marvel.rest;

import com.bim.marvel.openapi.client.dto.BackendApiDTO;
import com.bim.marvel.openapi.client.query.BackendApiDeleteQuery;
import com.bim.marvel.openapi.client.query.BackendApiQuery;
import com.bim.marvel.openapi.client.query.BackendApiUpdateQuery;
import com.bim.marvel.openapi.client.query.PageQuery;
import com.bim.marvel.common.core.model.dto.SimplePageVO;
import com.bim.marvel.common.core.model.dto.SimpleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;
import java.util.List;

/**
 * 〈后端开放API业务处理Controller〉
 *
 * @author Allen
 * @date 2020/8/26
 * @since 1.0.0
 */
@Api(tags = {"后端开放API业务处理-controller"})
@RequestMapping("/api/backend/api")
public interface BackendApiController {

    /**
     * 获得后端开放API实体列表请求URL
     */
    String GET_BACKEND_API_LIST_URL = "/list";

    /**
     * 刷新后端开放API实体列表请求URL
     */
    String REFRESH_BACKEND_API_URL = "/refresh";

    /**
     * 保存后端开放API实体信息请求URL
     */
    String BACKEND_API_SAVE_URL = "/save";

    /**
     * 删除后端开放API实体信息请求URL
     */
    String BACKEND_API_REMOVE_URL = "/remove";

    /**
     * 更新AppDateil实体信息请求URL
     */
    String BACKEND_API_UPDATE_URL = "/update";

    /**
     * 保存后端开放API接口信息
     * @param backendApiQuery 后端接口实体
     * @return 保存状态
     */
    @ApiOperation(value = "保存后端开放API接口信息", notes = "保存后端开放API接口信息",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = BACKEND_API_SAVE_URL, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<Boolean> saveBackendApi(@Valid BackendApiQuery backendApiQuery);

    /**
     * 更新后端开放API接口信息
     * @param backendApiQuery 后端接口实体
     * @return 更新状态
     */
    @ApiOperation(value = "更新后端开放API接口信息", notes = "更新后端开放API接口信息",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = BACKEND_API_UPDATE_URL, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<Boolean> updateBackendApi(@Valid BackendApiUpdateQuery backendApiQuery);

    /**
     * 删除后端开放API接口信息
     * @param backendApiDeleteQuery 删除后端API接口入参信息
     * @return 是否操作成功标识
     */
    @ApiOperation(value = "删除后端开放API接口信息", notes = "删除后端开放API接口信息",
            protocols = "http,https", httpMethod = "POST")
    @PostMapping(value = BACKEND_API_REMOVE_URL, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
            produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<Boolean> removeById(@Valid BackendApiDeleteQuery backendApiDeleteQuery);

    /**
     * 获得后端开放API实体信息列表
     * @param backendApiQuery 后端接口实体
     * @param pageQuery 分页入参
     * @return 后端开放API实体信息列表
     */
    @ApiOperation(value = "获得后端开放API实体信息列表", notes = "获得后端开放API实体信息列表",
            protocols = "http,https", httpMethod = "GET")
    @GetMapping(value = GET_BACKEND_API_LIST_URL, produces = {MediaType.APPLICATION_JSON_VALUE})
    SimplePageVO<List<BackendApiDTO>> listBackendApi(@Valid BackendApiQuery backendApiQuery, PageQuery pageQuery);


    /**
     * 刷新后端开放API实体Redis信息列表
     * @return 刷新结果(成功/失败)
     */
    @ApiOperation(value = "刷新后端开放API实体Redis信息列表", notes = "刷新后端开放API实体Redis信息列表",
            protocols = "http,https", httpMethod = "GET")
    @GetMapping(value = REFRESH_BACKEND_API_URL, produces = {MediaType.APPLICATION_JSON_VALUE})
    SimpleVO<Boolean> refreshBackendApi();


}
